package com.sdk.auth.exception;


import com.sdk.auth.enums.AuthErrorResultCode;

/**
 * @author wst
 * @date 2022/8/26
 * 自定义异常，可以全局捕获返回
 */
public class AuthException extends RuntimeException {

    private Integer code;

    private String message;

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public AuthException(String message) {
        this.message = message;
    }

    public AuthException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public AuthException(Throwable cause) {
        super(cause);
    }

    public AuthException(String message, Throwable cause) {
        super(message, cause);
    }

    public AuthException(AuthErrorResultCode e) {
        this.code = e.getCode();
        this.message = e.getMsg();
    }

    public AuthException(AuthErrorResultCode e, String msg) {
        this.code = e.getCode();
        this.message = e.getMsg() + ":" + msg;
    }
}
